/**
 * Created by ${PRODUCT_NAME}.
 * User: genell
 * Date: 1/8/11
 * Time: 5:50 PM
 * To change this template use File | Settings | File Templates.
 */
package com.thoughtorigin.util {
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.display.DisplayObjectContainer;

    public function removeAllChildren(container: DisplayObjectContainer, recursive: Boolean = true): void {
        if(!container) return;
        if(recursive && container.numChildren > 0 && container.getChildAt(0) is DisplayObjectContainer) {
            removeAllChildren(DisplayObjectContainer(container.getChildAt(0)), recursive);
        }
        while(container.numChildren > 0) {
            var disp: DisplayObject = container.removeChildAt(0);
            if(!disp) {
                break;
            }
        }
    }
}
